<?php
defined('_JEXEC') or die('Restricted access'); 
JHTML::_('behavior.tooltip'); 
 
$listOrder	= @$this->lists['order'];
$listDirn	= @$this->lists['order_Dir'];
defined('_JEXEC') or die('Restricted access');
?>
<script src="<?php echo JURI::base(true)?>/components/com_wrd/assets/js/jquery.min.js"></script>
<script src="<?php echo JURI::base(true)?>/components/com_wrd/assets/js/jquery.migrate.js"></script>

<script type="text/javascript">
function submitform(pressbutton)
{
	var form = document.adminForm;
   	if (pressbutton)
	{form.task.value=pressbutton;}

	if ((pressbutton=='add')||(pressbutton=='publish') ||(pressbutton=='unpublish')||(pressbutton=='remove'))
	{
	  	form.controller.value="products";
	}
	try 
	{
		form.onsubmit();
	}
	catch(e){}
	form.submit();
	
	
}

function listItemTaskHack(user_id,task) {
	$.ajax({
	  type: "POST",
	  url: "index.php?option=com_wrd&controller=upgradeuser&task="+task,
	  data: { id: user_id }
	}).done(function( msg ) {
	  if(msg == 'publish')
	  	$('#st_'+user_id).html('<img src="administrator/templates/bluestork/images/admin/publish_x.png" alt="Unpublished">');
	  else
	  	$('#st_'+user_id).html('<img src="administrator/templates/bluestork/images/admin/tick.png" alt="Unpublished">');
	});
}
</script>
<form id="adminForm"  action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" >
	<?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
	<?php else : ?>
		<div id="j-main-container">
	<?php endif;?>
		<br clear="all">	
    	<div id="filter-bar" class="btn-toolbar">
		<div class="filter-search btn-group pull-left fltlft">
			<label for="filter_search" class="element-invisible">Search</label>
			<input type="text" name="search" id="search" 
			placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" 
			value="<?php echo $this->search ?>"  title="" />
		</div>		
		<div class="filter-search btn-group pull-left fltlft">
			<button type="submit" class="btn"><i class="icon-search"></i></button>
			<button type="button" class="btn" onclick="document.id('search').value=''; this.form.submit();"><i class="icon-remove"></i></button>
		</div>
		<div class="btn-group pull-right hidden-phone fltrt">
			<?php
				echo $this->lists['published'];
				echo $this->lists['user'];
			?>
		</div>
	</div>
    <div id="editcell">
		<table class="table table-striped adminlist">
		<thead>
			<tr>
				<th width="5">
					<?php echo JText::_( 'NUM' ); ?>
				</th>
				<th width="20">
					<?php echo JHtml::_('grid.checkall'); ?>
				</th>
				<th width="20">
					<?php echo JHTML::_('grid.sort',  'user id', 'p.user_id', $listDirn, $listOrder ); ?>
				</th>
           		<th class="title" width="20%">
                	<?php echo JHTML::_('grid.sort',  'Member id', 'p.member_id', $listDirn, $listOrder ); ?>
               	</th>
               	<th class="title" width="20%">
                	<?php echo JHTML::_('grid.sort',  'Name', 'p.f_name', $listDirn, $listOrder ); ?>
               	</th>
               	<th class="title" width="20%">
                	<?php echo JHTML::_('grid.sort',  'Point', 'p.p_o_u', $listDirn, $listOrder ); ?>
               	</th>
                <th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Published', 'u.published', $listDirn, $listOrder ); ?>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
           $k = 0;
		for ($i=0, $n= count( $this->items ); $i < $n; $i++):
			$row = &$this->items[$i];
			$canChange = true;
			?>
			<tr class="<?php echo "row$k"; ?>"  >
                <td>
					<?php echo($i+1); ?>
				</td>
                <td>
					<?php echo $checked; ?>
				</td>
				<td>
					<?php echo $row->user_id; ?>
				</td>
				<td>
					<?php echo $row->member_id; ?>
				</td>
				<td>
					<?php echo $row->f_name.' '.$row->l_name; ?>
				</td>
				<td>
					<?php echo $row->p_o_u; ?>
				</td>
                <td id="st_<?php echo $row->user_id; ?>">
					<?php if($row->published == 0): ?>
						<a href="javascript:void(null)" onclick="return listItemTaskHack('<?php echo $row->user_id; ?>','publish')" title="Publish Item">
							<img src="administrator/templates/bluestork/images/admin/tick.png" alt="Unpublished">
						</a>
					<?php else: ?>
						<a href="javascript:void(null)" onclick="return listItemTaskHack('<?php echo $row->user_id; ?>','unpublish')" title="Publish Item">
							<img src="administrator/templates/bluestork/images/admin/publish_x.png" alt="Unpublished">
						</a>
					<?php endif; ?>
				</td>
			</tr>
			<?php
            $k = 1 - $k;
		endfor
		?>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="16">
                    <?php
                         echo $this->pagination->getListFooter();
                    ?>
                </td>
			</tr>
		</tfoot>
		</table>
	</div>

	<input type="hidden" name="controller" value="upgradeuser" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>

